/***************************************************************************
 *   mgpi_g2dmdl.h - 2D Graphics Declarations                              *
 *   Copyright (C) 2008 by cmaster.matso                                   *
 *   cmaster.matso@gmail.com                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef _G2DMDL_H
#define _G2DMDL_H

#ifdef __cplusplus
extern "C" {
#endif

#include "../../grbclr/src/mgpi_grbclr.h"

#pragma pack(push, 1)

    typedef struct _graphic {
        void *vparam;                                                           /** auxiliary pointer */
        SDL_Surface *image;                                                     /** SDL graphic surface pointer */
        const char *image_name;                                                 /** graphic image name */
    } graphic_t;                                                                /** surface graphic */

#pragma pack(pop)

    /**
     * Loads from file an image of the given name.
     */
    SDL_Surface MGPI_API *g2dLoadImage(const char *filename);

    /**
     * Loads an image of the given name and draw it on the given surface.
     */
    MGPI_BOOL MGPI_API g2dDrawImage(SDL_Surface *surface, const char *name, int x, int y);

    /**
     * Draws the given source surface to the given destination surface.
     */
    MGPI_BOOL MGPI_API g2dDrawSurface(SDL_Surface *dest_surf, SDL_Surface *src_surf, int x, int y);

    /**
     * Splits the given image into an array of sub images of given width and height.
     */
    MGPI_BOOL MGPI_API g2dSplitImage(graphic_t *g[], int glen, SDL_Surface *image, int w, int h);

    /**
     * Clips the given image by the sizes and position given.
     */
    SDL_Surface MGPI_API *g2dClipImage(SDL_Surface *image, int x, int y, int w, int h);

    /**
     * Gets pixel unsigned integer value form the given surface position.
     */
    Uint32 MGPI_API g2dGetPixel(SDL_Surface *surface, int x, int y);

    /**
     * Sets a given pixel unsigned integer value to the position given upon the surface.
     */
    void MGPI_API g2dPutPixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
    
#ifdef __cplusplus
}
#endif

#endif
